<template>
  <div class="my_div">
    <img :src="url" alt="" />
    <p
      :class="{ blue: num === 1, red: num === 2, purple: num === 3 }"
      @click="changeColorAdd"
    >
      {{ name }}
    </p>
  </div>
</template>

<script>
export default {
  props: ["url", "name"],
  data() {
    return {
      num: 0,
    };
  },
  methods: {
    changeColorAdd() {
      this.num++;
      if (this.num === 3) {
        this.num = 0;
      }

    },
  },
};
</script>

<style lang="css" scoped>
.blue {
  background-color: blue;
}
.red {
  background-color: red;
}
.purple {
  background-color: purple;
}
.my_div {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.my_div img {
  width: 100%;
  height: 200px;
}
</style>